package org.carabiner.infopanel;

import java.awt.Label;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JLabel;

public class EmptyJLabelRule extends AbstractRule
{
  protected List inspectLabel(Label label)
  {
    if (label.getText() == null || label.getText().equals(""))
    {
      List warnings = new ArrayList(1);
      warnings.add(createWarning(label));
      return warnings;
    }
    return super.inspectLabel(label);
  }

  protected List inspectJLabel(JLabel label)
  {
    if ((label.getText() == null || label.getText().equals(""))
        && label.getIcon() == null)
    {
      List warnings = new ArrayList(1);
      warnings.add(createWarning(label));
      return warnings;
    }
    return super.inspectJLabel(label);
  }

  public String getName()
  {
    return "Empty Label";
  }

  public String getDescription()
  {
    return "This label has no text or icon";
  }
}
